import 'package:flutter/material.dart';

class TagMenuItem extends StatelessWidget {
  final Widget icon;
  final String text;
  final double? size;
  final double aspectRatio;
  final Widget? badge;
  final Color? backgroundColor;
  final void Function()? onTap;

  const TagMenuItem({
    Key? key,
    required this.icon,
    required this.text,
    this.onTap,
    this.size,
    this.aspectRatio = 1,
    this.badge,
    this.backgroundColor,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      width: size,
      height: size == null ? null : size! * aspectRatio,
      color: backgroundColor,
      child: InkWell(
        onTap: onTap,
        child: Stack(
          children: [
            Align(
              alignment: Alignment.center,
              child: Column(
                mainAxisAlignment: MainAxisAlignment.spaceAround,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  icon,
                  Text(
                    text,
                    softWrap: false,
                  ),
                ],
              ),
            ),
            if (badge != null)
              Align(
                alignment: const Alignment(0, -1),
                child: Padding(
                  padding: const EdgeInsets.only(left: 32),
                  child: badge!,
                ),
              ),
          ],
        ),
      ),
    );
  }
}
